package com.copm.ifm.base.service.interceptor;

import com.copm.ifm.base.basic.constant.AuthConstants;
import com.copm.ifm.base.basic.util.AuthUtils;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.stereotype.Component;

/**
 * feign参数拦截
 * <p>
 * 在调用其他服务时将token插入请求头中，类似于Dubbo的隐式传参
 *
 * @author zzf
 * @date 2020/8/4 10:47
 */
@Component
public class FeignParamsInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate requestTemplate) {
        requestTemplate.header(AuthConstants.TOKEN_NAME, AuthUtils.getCurrentToken());
    }
}
